package com.sbw.job.demo.service.impl;

import com.sbw.job.demo.mapper.HotelPostingDetailMapper;
import com.sbw.job.demo.model.HotelPostingDetail;
import com.sbw.job.demo.service.HotelPostingDetailService;
import com.sbw.job.demo.utils.ConvertBeanUtils;
import com.sbw.job.demo.controller.request.PostingDetailSearchRequest;
import com.sbw.job.demo.controller.vo.PostingDetailVO;
import com.sbw.job.demo.mapper.HotelPostingDetailMapper;
import com.sbw.job.demo.model.HotelPostingDetail;
import com.sbw.job.demo.service.HotelPostingDetailService;
import com.sbw.job.demo.utils.ConvertBeanUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author: sangbowei
 * @Description:
 * @Date: 2018/9/5 19:50
 */
@Slf4j
@Service
public class HotelPostingDetailServiceImpl implements HotelPostingDetailService {


	@Resource
	private HotelPostingDetailMapper hotelPostingDetailMapper;

	@Override
	public List<PostingDetailVO> findPostingDetailList(PostingDetailSearchRequest searchRequest) {

		List<HotelPostingDetail> postingDetailList = hotelPostingDetailMapper.findPostingDetailList(searchRequest);
		if(CollectionUtils.isEmpty(postingDetailList)){
			return null;
		}

		List<PostingDetailVO> postingDetailVOList = new ArrayList<>();
		ConvertBeanUtils.copyListBeanPropertiesToList(postingDetailList,postingDetailVOList,PostingDetailVO.class);

		return postingDetailVOList;
	}
}
